<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/public/header.jsp"%>
<%
    String gd_id = request.getParameter("gd_id") == null ? "" : request.getParameter("gd_id");
	String gd_code = request.getParameter("gd_code") == null ? "" : request.getParameter("gd_code");
	String gd_name = request.getParameter("gd_name") == null ? "" : request.getParameter("gd_name");
	String is_closed = request.getParameter("is_closed") == null ? "0" : request.getParameter("is_closed");
%>
<html>
	<head>
		<title>安质检查</title>
	</head>
	<script type="text/javascript">
	
	$(function(){
		$("#searchValueTwo").keypress(function(e) { 
	    	// 回车键事件 
	     	if(e.which == 13) { 
	     		 doSearch();
	       	} 
	   	}); 
		$('#table').datagrid({
			iconCls:'icon-edit',
			url:'<%=contextPath %>/springMVC/gd/listSecurity?gd_id=<%=gd_id%>',
			loadMsg:'正在加载数据，请稍后......',
			fitColumns:true,
			frozenColumns:[[
                {field:'ck',checkbox:true},
			    {title:'编号',field:'id',width:5,sortable:true,hidden:true}
			]],
			columns:[[
				{title:'安质标题',field:'title',width:100,align:'center'},
				{title:'检查时间',field:'check_operation_date',width:100,align:'center',sortable:true},
				{title:'安质摘要',field:'remark',width:250,align:'center'},
				{title:'查看',field:'edit',width:50,align:'center',formatter:function(value,rowDate,rowIndex){
					return "<input type='button'  style='border:0px #ff0000 solid;width:25px;height:15px;cursor:pointer' class='icon-details' title='查看'  onClick='addOrEditSecurity(3,\""+rowIndex+"\")'/>";
					
		}}

			]],
			
			pageSize:10,
			pageList : [10,50,100],  
			pagination:true,
			onLoadSuccess:function(rtJson){
				if(rtJson.rtState== '1')
				{
					$.messager.alert('提示',rtJson.rtMsrg);
				}
			},
			onDblClickRow:function(rowIndex,rowData){
				addOrEditUser(1,rowIndex);
			}
		});
		//--end 
	});
	function addOrEditSecurity(type,rowIndex){
			var row = $('#table').datagrid("getRows")[rowIndex];
		if(type==0){
			openDialogResize('<%=contextPath %>/springViews/gd/addOrEditSecurity.jsp?callback=rtCallBack&gd_id=<%=gd_id %>&gd_name=<%=gd_name%>&gd_code=<%=gd_code%>',1000, 800);
		}else if(type==1){
			openDialogResize('<%=contextPath %>/springViews/gd/addOrEditSecurity.jsp?callback=rtCallBack&id='+row.id+'&gd_id=<%=gd_id %>&gd_name=<%=gd_name%>&gd_code=<%=gd_code%>',1000, 800);
		}else{
			openDialogResize('<%=contextPath %>/springViews/gd/addOrEditSecurity.jsp?isShow=1&callback=rtCallBack&id='+row.id+'&gd_id=<%=gd_id %>&gd_name=<%=gd_name%>&gd_code=<%=gd_code%>',1000, 800);
			
		}
	}
	function rtCallBack(){
		$('#table').datagrid('reload');
	}
	
	function deleteRows(){
		var rows=$('#table').datagrid('getSelections');
		var deleteVar="";
		if(rows.length==0)
		{
			$.messager.alert('提示','选中要删除的记录');  
			return ;
		}
		for(var i=0;i<rows.length;i++)
		{
			if(i==(rows.length-1))
			{
				deleteVar+=rows[i].id;
			}else
			{
				deleteVar+=rows[i].id+",";
			}
		}
		$.messager.confirm('确认','您确认删除该记录信息？',function(msg){
			if(msg){
				$.ajax({
					type:'POST',
					url:"<%=contextPath %>/springMVC/gd/deleteSecurity",
					data:"ids="+deleteVar,
					dataType:"json",
					success:function(rtJson){
						if(rtJson.rtState == '0'){
							table_reload(rows.length);
						}
						else{
							$.messager.alert('提示：',rtJson.rtMsrg);
						}
					}
				});
			}
		});
	}
	function doSearch()
	{
		var start_time=$('#start_time').datebox('getValue');  
		var end_time=$('#end_time').datebox('getValue');  
		var searchValueTwo = $('#searchValueTwo').val();
		$('#table').datagrid('load',{
			searchValueTwo:searchValueTwo,
			start_time:start_time,
			end_time:end_time
		});
	}
	</script>
<body>
	<div id="table"  data-options="toolbar:'#tb',fit:true"></div>  
	  
    <div id="tb" style="padding:3px;height:auto">
    <%if(!"1".equals(is_closed)){%>
		<div style="float:left;">
			<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="deleteRows();">删除</a>
			<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="addOrEditSecurity(0);">添加安质</a>
		</div>
		<%}%>
		<div align="right">
			 开始时间：<input id="start_time" name="start_time" class="easyui-datebox" />&nbsp;&nbsp;&nbsp;结束时间：<input id="end_time" name="end_time" class="easyui-datebox" />
			安质标题：<input id="searchValueTwo" name="searchValueTwo" style="width:150px" title="安质标题" />&nbsp;&nbsp; 
			<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="doSearch();"></a>
		</div>
	</div>
	
</body>
</html>
